package cn.tedu.egmvc01.controller;

import cn.tedu.egmvc01.pojo.dto.Employees;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class EmployeesController {
    @RequestMapping("/emp/insert")
    @ResponseBody
    public String addEmployee(Employees employees){
        String name = employees.getName();
        System.out.println("name = " + name);
        Double salary = employees.getSalary();
        System.out.println("salary = " + salary);
        String job = employees.getJob();
        System.out.println("job = " + job);
        return "添加成功";
    }

    @RequestMapping("/emp/select")
    @ResponseBody
    public String selectAllEmployees(){
        System.out.println("查询数据库中所有的信息");
        return "查询成功";
    }

    @RequestMapping("/emp/update")
    @ResponseBody
    public String updateEmployee(Employees employees){
        Long id = employees.getId();
        System.out.println("id = " + id);
        String name = employees.getName();
        System.out.println("name = " + name);
        Double salary = employees.getSalary();
        System.out.println("salary = " + salary);
        String job = employees.getJob();
        System.out.println("job = " + job);
        return "修改成功";
    }

    @RequestMapping("/emp/delete")
    @ResponseBody
    public String deleteEmployee(Long id){
        System.out.println("id = " + id + "已经被删除");
        return "删除成功";
    }
}
